﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace EditTable
{
    public partial class FormEdit : System.Web.UI.Page
    {
        static Category category = new Category();
        protected void Page_Load(object sender, EventArgs e)
        {
            int id = int.Parse(Request.Params["ID"]);
            Response.Write(id);
            if (!IsPostBack)
            {
                category = NorthWindClass.GetCategoryByID(id);
                if (category != null)
                {
                    this.textBoxName.Text = category.CategoryName;
                    this.textBoxDescription.Text = category.Description;
                }
            }
        }

        protected void buttonEdit_Click(object sender, EventArgs e)
        {
            category.CategoryName = this.textBoxName.Text;
            category.Description = this.textBoxDescription.Text;
            NorthWindClass.Submit();
            Response.Redirect("~/FormView.aspx");
        }

        protected void buttonCancel_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/FormView.aspx");
        }
    }
}